/**
 * 当前项目的全局方法
 * */
import Vue from 'vue'
import store from '../store'


export default {
  showPicker(obj = {}) {
    let {sure, change,close} = obj;
    let Picker = Vue.extend(require('../components/pickerapi').default);
    let picker = new Picker({el: document.createElement('div')});
    if (typeof sure !== 'function') {
      sure = (res, fn) => fn();
    }
    if (typeof change !== 'function') {
      change = new Function();
    }
    if (typeof close !== 'function') {
      close = new Function();
    }
    picker.$on('sure', sure);
    picker.$on('change', change);
    picker.$on('close',close)
    delete obj.sure;
    delete obj.change;
    delete obj.close;
    Object.assign(picker, obj);
    document.body.appendChild(picker.$el);
    return picker;
  },
  showUserPopup() {
    store.commit('setLeftScope', true);
  }
}